{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
  <h3 class="pb-3">重置密码</h3>
  <table class="layui-table layui-table-form">
    <tr>
      <td class="layui-td-gray">用户名 <font>*</font></td>
      <td><input type="text" lay-verify="required" autocomplete="off" placeholder="" class="layui-input"
          value="{$admin.username}" disabled></td>
      <td class="layui-td-gray">旧密码<font>*</font></td>
      <td>
        <input type="password" lay-verify="required" name="old_pwd" placeholder="请输入旧密码" lay-reqText="请输入旧密码"
          autocomplete="off" class="layui-input">
      </td>
    </tr>
    <tr>
      <td class="layui-td-gray">新密码 <font>*</font></td>
      <td>
        <input type="password" lay-verify="required" name="pwd" placeholder="请输入新密码" lay-reqText="请输入新密码"
          autocomplete="off" class="layui-input">
      </td>
      <td class="layui-td-gray-2">确认新密码 <font>*</font></td>
      <td>
        <input type="password" lay-verify="required" name="pwd_confirm" placeholder="请再次输入新密码" lay-reqText="请再次输入新密码"
          autocomplete="off" class="layui-input">
      </td>
    </tr>
  </table>
  <div class="py-3">
    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
  const moduleInit = ['tool'];
  function gouguInit() {
    var form = layui.form, tool = layui.tool;
    //监听提交
    form.on('submit(webform)', function (data) {
      let callback = function (e) {
        layer.msg(e.msg);
        if (e.code == 0) {
          layer.confirm('修改密码成功,关闭本页面吗?', { icon: 3, title: '提示' }, function (index) {
            TAB.sonDelete();
            layer.close(index);
          });
        }
      }
      tool.post("/admin/api/password_submit", data.field, callback);
      return false;
    });
  }
</script>
{/block}
<!-- /脚本 -->